<?php 
//if (!defined('BASEPATH'))exit('No direct script access allowed');

class Login extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
    }
    
    public function index()
    {
        if($this->session->userdata('logged_in') == true)
        {
            $this->template->admin('admin/v_main_page', null, 1);
        }
        else
        {
            $data['TITLE'] = "Halaman Login";
            $this->load->view("admin/v_login", $data);    
        }
    }
    
    public function proses_login()
    {
        $username = $this->input->post('username');
        $password = $this->input->post('password');
//        $username = 'iyong';
//        $password = 'aa';
        if($username != "" && $password != "")
        {
            if($this->authlogin->login($username, $password) == true)
            {
                $this->db->set('login_akhir', 'NOW()', FALSE)->where('username_adm', $username)->update('adm_user');
                echo 'OK';
            }
            else
            {
                echo '<div class="alert alert-error">
						<button data-dismiss="alert" class="close" type="button">x</button>
						<div id="message_value"><strong>Gagal Masuk</strong> username atau password salah</div>
					</div><!--alert-->';
            }
        }
        else
        {
            show_404();
        }
    }
    
    public function logout()
    {
        $this->authlogin->logout('logged_in');
        redirect('admin');
    }
}

/* End of file login.php */
/* Location: ./application/controllers/admin/login.php */